<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="../../../js/jquery.js"></script>
<script type="text/javascript" src="../../../js/jquery-ui-personalized.min.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/repair.js"></script>
<link type="text/css" href="../../../style/theme/ui.all.css" rel="stylesheet" />
<link type="text/css" href="../style/style.css" rel="stylesheet"/>
<title>保修单列表</title>
</head>
<body>
	<div class="ajaxMessage"></div>
	<h1>${student.dormitory.name }的保修列表</h1>
	<div class="filterForm">
		<form action="repairList.do" method="get">
			<select name="type">
				<option value="dormitory">寝室</option>
			</select>
			<span>受理</span><span><input type="checkbox" name="processed"/></span>
			<span>处理</span><span><input type="checkbox" name="applied"/></span>
			<span>起始时间:</span><span><input type="text" name="fromDate" class="datepicker"/></span>
			<span>结束时间:</span><span><input type="text" name="toDate" class="datepicker"/></span>
			<input type="submit" name="submit" value="查询"/>
		</form>
	</div>
	
	<c:choose>
		<c:when test="${!empty repairs.list}">
			<div class="modifyDialog" title="查看/更新">
				<form action="updateRepair.do" name="updateRepairForm" method="post">
					<input type="hidden" name="repairId"/>
					<div title="查看/修改">
						<label for="title">*标题</label>
						<div><input type="text" name="title" id="title"/></div>
					</div>
					<div>
						<label for="reason">*原因</label>
						<div><textarea rows="7" cols="25" name="reason" id="reason"></textarea></div>
					</div>
				</form>			
			</div>
			<div>
				<input type="button" name="delete" value="删除"/>
			</div>
			<table border="1px" id="repairs">
				<thead>
					<tr>
						<td><input type="checkbox" name="checkAll"/></td>
						<th>ID</th><th>标题</th><th>原因</th><th>申请人</th>
						<th>申请时间</th><th>受理</th><th>受理时间</th>
						<th>处理</th><th>处理时间</th><th>查看/修改</th>
					</tr>
					
				</thead>
				<tbody>
					<c:forEach items="${repairs}" var="repair">
						<tr>
							<td><input type="checkbox" value="${repair.id }" name="item" ${repair.status.processed ? "disabled='disabled'" : "" }/></td>
							<td title="id">${repair.id }</td><td title="title">${repair.title }</td>
							<td title="reason">${repair.reason }</td><td>${repair.student.realName }</td>							
							<td><fmt:formatDate value="${repair.requestDate}" pattern="yyyy-MM-dd HH:mm"/></td>
							<td>状态<input type="checkbox" name="processed" ${repair.status.processed ? "checked=\"checked\"" : "" }
										disabled="disabled"/></td>
							<td>
								<c:choose>
									<c:when test="${!empty repair.status.processDate}">
										<fmt:formatDate value="${repair.status.processDate}" pattern="yyyy-MM-dd HH:mm"/>
									</c:when>
									<c:otherwise>暂无</c:otherwise>
								</c:choose>				
							</td>
							<td>状态<input type="checkbox" name="applied" disabled="disabled" 
									${repair.status.applied ? "checked='checked'" : "" }/></td>
							<td>
								<c:choose>
									<c:when test="${!empty repair.status.applyDate}">
										<fmt:formatDate value="${repair.status.applyDate}" pattern="yyyy-MM-dd HH:mm"/>
									</c:when>
									<c:otherwise>暂无</c:otherwise>
								</c:choose>		
							</td>	
							<td><input type="button" name="modify" value="查看/修改"/></td>						
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<div>
				<input type="button" name="delete" value="删除"/>
			</div>
		</c:when>	
		<c:otherwise>
			<p>没有找到符合条件的保修单</p>
		</c:otherwise>
	</c:choose>
</body>
</html>